package JET.Frames;

import java.awt.Point;
import java.awt.event.MouseEvent;
import javax.swing.JDialog;
import javax.swing.event.MouseInputListener;

/**
 *
 * @author 057Ry
 */
public class DragDialogMouseInputListener implements MouseInputListener
{

    private final JDialog owner;
    private Point localPressPoint;

    public DragDialogMouseInputListener(JDialog dialog)
    {
        owner = dialog;
    }

    public void mouseClicked(MouseEvent e) {}

    public void mousePressed(MouseEvent e)
    {
        localPressPoint = e.getPoint();
    }

    public void mouseReleased(MouseEvent e) {}
    public void mouseEntered(MouseEvent e) {}
    public void mouseExited(MouseEvent e) {}

    public void mouseDragged(MouseEvent e)
    {
        setOwnerOnScreenLocation( e.getLocationOnScreen() );

//        if (owner instanceof PrimsDialog)
//        {
//            ((PrimsDialog)owner).calcLocationRelativeToMainFrame();
//        }
//        if (owner instanceof BodiesDialog)
//        {
//
//        }

    }

    public void mouseMoved(MouseEvent e) {}

    public void setOwnerOnScreenLocation(Point p)
    {
        owner.setLocation( new Point( p.x-localPressPoint.x, p.y-localPressPoint.y) );
    }

}

